﻿<%@ Page Title="Duyệt thông tin đăng ký bảo hành" Language="C#" MasterPageFile="~/App_MasterPages/Aquarius.Master"
    AutoEventWireup="true" CodeBehind="ApproveWarrantyManagement.aspx.cs" Inherits="PanasonicWarranty.UI.ApproveWarrantyManagement"  %>

<%@ Register Src="../UserControl/ucPaging.ascx" TagName="ucPaging" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CssContent" runat="server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        function pageLoad(sender, args) {
            RegisterDialog();
            ComboBox("ddlSearchAgency,ddlSearchModel");
            DatePicker("txtSearchFromDate,txtSearchToDate");
            $("[id$=ddlSearchCategory]").closest("td").find(".custom-combobox-input").focus();
        }

        function ApproveWarranty(id) {
            $.ajax({
                type: "POST",
                url: 'ApproveWarrantyManagement.aspx/ApproveWarranty',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                beforeSend: function () {
                    $("#progress").show();
                },
                complete: function () {
                    $("#progress").hide();
                },
                data: "{'id':" + JSON.stringify(id) + "}",
                success: function (data) {
                    $("[id$=txtSms]").html(data.d);
                    ShowCount($("[id$=txtSms]"));
                    $("[id$=hdfID]").val(id);
                    OpenDialog('dialog1', 500);
                }
            });
            return false;
        }
        function RejectWarranty(id) {
            $("[id$=hdfID]").val(id);
            $("[id$=txtRejectWarranty]").val("");
            OpenDialog('dialog4', 500);
            return false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="row-fluid">
        <div class="span12">
            <div class="head">
                <div class="isw-grid">
                </div>
                <h1>Điều kiện tìm kiếm</h1>
                <div class="clear"></div>
            </div>
            <div class="block-fluid" style="padding: 10px 0px 5px 10px">
                <asp:UpdatePanel ID="udpn1" runat="server">
                    <ContentTemplate>
                        <table width="100%" cellspacing="0" cellpadding="0" class="">
                        <tbody>
                            <tr>
                                <td>Nhóm sản phẩm</td>
                                <td><asp:DropDownList ID="ddlSearchCategory" runat="server" OnSelectedIndexChanged="ddlSearchCategory_SelectedIndexChanged" AutoPostBack="true"/></td>
                                <td>Model sản phẩm</td>
                                <td><asp:DropDownList ID="ddlSearchModel" runat="server" /></td>
                                <td>Số máy</td>
                                <td><asp:TextBox ID="txtSearchProductCode" runat="server" /></td>
                            </tr>
                            <tr>
                                <td>Đại lý nhắn tin</td>
                                <td><asp:DropDownList ID="ddlSearchAgency" runat="server" /></td>
                                <td>Ngày mua hàng</td>
                                <td><asp:TextBox ID="txtSearchFromDate" runat="server" /></td>
                                <td>Đến</td>
                                <td><asp:TextBox ID="txtSearchToDate" runat="server" /></td>
                            </tr>
                            <tr>
                                <td>Điện thoại KH</td>
                                <td>
                                    <asp:TextBox ID="txtSearchPhone" runat="server" onkeypress="return ValidateKeypress(/\d+/,event);" />
                                </td>
                                <td>Bắt buộc happy call</td>
                                <td>
                                    <asp:DropDownList ID="ddlSearchHappyCall" runat="server">
                                        <asp:ListItem Value="" Text="" />
                                        <asp:ListItem Value="true" Text="Có" />
                                        <asp:ListItem Value="false" Text="Không" />
                                    </asp:DropDownList>
                                </td>
                                <td>&nbsp;</td><td>&nbsp;</td>
                            </tr>
                        </tbody>
                    </table>
                    <div style="text-align: center">
                        <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" OnClick="btnSearch_Click" CssClass="btn" />
                    </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <div class="head">
                <div class="isw-grid"></div>
                <h1>Danh sách sản phẩm chờ duyệt bảo hành</h1>
                <ul class="buttons">
                <li>
                    <asp:LinkButton CssClass="isw-download" ID="btnExport" runat="server" 
                        ToolTip="Xuất ra file excel" onclick="btnExport_Click"/>
                </li>
            </ul>
                <div class="clear"></div>
            </div>
            <div class="block-fluid table-sorting">
                <asp:UpdatePanel ID="udpn2" runat="server">
                    <ContentTemplate>
                        <div class="dataTables_wrapper" id="tSortable_wrapper">
                            <div class="dataTables_length">
                                <label>
                                    Hiển thị
                                    <asp:DropDownList ID="tSortable_length" size="1" aria-controls="tSortable" runat="server"
                                        OnSelectedIndexChanged="tSortable_length_SelectedIndexChanged" AutoPostBack="true">
                                        <asp:ListItem Value="5">5</asp:ListItem>
                                        <asp:ListItem Value="10">10</asp:ListItem>
                                        <asp:ListItem Value="25">25</asp:ListItem>
                                        <asp:ListItem Value="50" Selected="True">50</asp:ListItem>
                                        <asp:ListItem Value="100">100</asp:ListItem>
                                        <asp:ListItem Value="200">200</asp:ListItem>
                                        <asp:ListItem Value="250">250</asp:ListItem>
                                        <asp:ListItem Value="300">300</asp:ListItem>
                                    </asp:DropDownList>
                                    dòng</label>
                            </div>
                            <div>
                                <uc1:ucPaging ID="pagingtop" runat="server" />
                            </div>
                            <asp:GridView ID="grvData" CssClass="table2 dataTable" runat="server" 
                                AutoGenerateColumns="false" Width="100%"
                                ShowHeaderWhenEmpty="true">
                                <Columns>
                                    <asp:TemplateField HeaderText="STT" ItemStyle-CssClass="STT">
                                        <ItemTemplate>
                                            <%#(Container.DataItemIndex + 1) + (pagingtop.CurrentPage - 1) * pagingtop.PageSize%>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Đại lý">
                                        <ItemTemplate>
                                            <%#pa_Agency.GetAgencyName(Eval("AgencyID"))%>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField HeaderText="Điện thoại KH" DataField="CustomerPhone" ItemStyle-CssClass="Phone" />
                                    <asp:BoundField HeaderText="Model" DataField="ModelCode" ItemStyle-CssClass="width1"/>
                                    <asp:BoundField HeaderText="Số máy" DataField="ProductCode" ItemStyle-CssClass="width2"/>
                                    <asp:BoundField HeaderText="Ngày mua hàng" DataField="RegisterDate" DataFormatString="{0:d}" ItemStyle-CssClass="DateTime" />
                                    <asp:BoundField HeaderText="Ngày ĐK" DataField="CreatedDate" DataFormatString="{0:d}" ItemStyle-CssClass="DateTime"/>
                                    <asp:BoundField HeaderText="Loại ĐK" DataField="WarrantyType" ItemStyle-CssClass="width3"/>
                                    <asp:BoundField HeaderText="ĐK qua" DataField="RegisteredFrom" ItemStyle-CssClass="width3"/>
                                    <asp:BoundField HeaderText="Gói GH" DataField="WarrantyPackageCode" ItemStyle-CssClass="width3"/>
                                    <asp:BoundField HeaderText="Thời hạn bảo hành" DataField="Detail" ItemStyle-CssClass="Description"/>
                                    <asp:TemplateField HeaderText="Chức năng" ItemStyle-Width="250px">
                                        <ItemStyle CssClass="Function" Width="100px" />
                                        <ItemTemplate>
                                            <a href="#" onclick='return ApproveWarranty(<%#Eval("WarrantyWattingID")%>);'>Duyệt</a>
                                            &nbsp; &nbsp;
                                            <a href="#" onclick='return RejectWarranty(<%#Eval("WarrantyWattingID")%>);'>Từ chối</a>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                            <div class="dataTables_info" id="tSortable_info">
                                <asp:Literal ID="ltrInfo" runat="server" />
                            </div>
                            <div class="dataTables_paginate paging_full_numbers" id="tSortable_paginate">
                                <uc1:ucPaging ID="pagingbottom" runat="server" />
                            </div>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <div class="clear">&nbsp;</div>
            </div>
        </div>
    </div>
    <div class="dialog" id="dialog1" title="Duyệt thông tin bảo hành" style="display: none;">
    <div class="block">
        <asp:UpdatePanel ID="pnlDialogBlock" runat="server">
            <ContentTemplate>
                <asp:HiddenField ID="hdfID" Value="" runat="server" />
                <div class="row-fluid">
                    <fieldset>
                        <legend>Gửi tin xác nhận bảo hành</legend>
                        <table width="100%">
                            <tr>
                                <td style="width:140px">Sender Name</td>
                                <td><asp:DropDownList ID="ddlShortCode" runat="server" /></td>
                            </tr>                
                            <tr>
                                <td>Nội dung tin nhắn</td>
                                <td><asp:TextBox ID="txtSms" runat="server" TextMode="MultiLine" onkeypress="return false"/></td>
                            </tr>
                            <tr>
                                <td>Số ký tự</td>
                                <td>
                                    <span id="lbletter">0</span> ký tự / <span id="lbmessage">1</span> tin nhắn
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="right">
                                    <asp:Button ID="btnSendSMS" runat="server" CssClass="btn" Text="Gửi tin" 
                                       style="width:80px" OnClick="btnSendSMS_Click"/>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </div>
                <div class="dr"><span></span></div>
                <div class="row-fluid">
                    <fieldset>
                        <legend>Thực hiện happy call</legend>
                        <table width="100%">
                            <tr>
                                <td>Xác nhận đã thực hiện happy call</td>
                                <td rowspan="2" align="right"><asp:Button ID="btnHappyCall" runat="server" CssClass="btn" Text="Xác nhận" 
                                    style="width:80px" OnClick="btnHappyCall_Click"/></td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label AssociatedControlID="chkSendSMS" runat="server" style="font-size:12px; display:inline">Kèm gửi tin nhắn xác nhận bảo hành </asp:Label>
                                    <asp:CheckBox ID="chkSendSMS" runat="server" Checked="true"/>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </div>
                <div style="text-align:center; width:100%; color:Red"><asp:Label ID="lbError" runat="server" /></div>
                <div class="dr"><span></span></div>
                <div style="text-align: right">
                    <input type="button" class="btn" value="Đóng" onclick="$('#dialog1').dialog('close'); return false;" style="width:80px"/>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </div>
    <div class="dialog" id="dialog4" title="Từ chối bảo hành" style="display: none;">
    <div class="block">
        <asp:UpdatePanel ID="pnl_dialog4" runat="server">
            <ContentTemplate>
                <div style="width:100%;">
                    <table width="100%">
                        <tr>
                            <td colspan="2"><span>Lý do từ chối bảo hành:</span></td>
                        </tr>
                        <tr>
                            <td><asp:TextBox ID="txtRejectWarranty" runat="server" TextMode="MultiLine" /></td>
                            <td><asp:Label ID="lbValidateRejectWarranty" style="color:Red" runat="server" /></td>
                        </tr>
                    </table>
                </div>
                <div class="dr"><span></span></div>
                <div style="text-align: right">
                    <asp:Button ID="btnRejectWarranty" runat="server" Text="Từ chối bảo hành" CssClass="btn" 
                        OnClick="btnRejectWarranty_Click"
                        OnClientClick="javascript:if($.trim($('[id$=txtRejectWarranty]').val())==''){$('[id$=lbValidateRejectWarranty]').html('(*)'); return false;}"/>
                    <input type="button" class="btn" value="Đóng" onclick="$('#dialog4').dialog('close'); return false;"/>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </div>
    <asp:UpdateProgress ID="prg" runat="server" DisplayAfter="500">
        <ProgressTemplate>
            <div class="ui-widget-overlay ui-front">
                <img src='<%=ResolveUrl("~/images/loading.gif")%>' alt="Loading..." style="position: fixed; top: 50%; left: 50%" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <div class="ui-widget-overlay ui-front" id="progress" style="display:none">
        <img src='<%=ResolveUrl("~/images/loading.gif")%>' alt="Loading..." style="position: fixed; top: 50%; left: 50%;" />
    </div>
</asp:Content>
